%table
  %tr.header
    %th
      %a{:href => '/?'+params.merge('sort' => :name).map{|pair| pair.join('=')}.join(';')} Project
    %th
      %a{:href => '/?'+params.merge('sort' => :elapsed).map{|pair| pair.join('=')}.join(';')} Work Time
    %th
      %a{:href => '/?'+params.merge('sort' => :last).map{|pair| pair.join('=')}.join(';')} Last Access
  
  - @projects.each do |project|
    - elapsed_time = project.work_time.to_i
    - hours        = elapsed_time/1.hour
    %tr
      %th{:title => project.name}
        %a.project{:href => "/project/#{project.name}", :title => "#{hours.to_i}h \n  eur#{hours*20}@eur20/h \n  eur#{hours*25}@eur25/h \n  eur#{hours*30}@eur30/h"}= project.name ? project.name.underscore.humanize : '<i>other</i>'
      %td
        - if elapsed_time < 1.hours
          = elapsed_minutes = elapsed_time / 1.minute
          = elapsed_minutes == 1 ? 'minute' : 'minutes'
        - elsif elapsed_time < 8.hours
          = elapsed_hours = elapsed_time / 1.hour
          = elapsed_hours == 1 ? 'hour' : 'hours'
        - else
          = elapsed_days  = elapsed_time / 8.hours
          man
          = elapsed_days  == 1 ? 'day'  : 'days'
          - if (elapsed_hours = (elapsed_time % 8.hours) / 1.hour) >= 1
            and
            = elapsed_hours
            = elapsed_hours == 1 ? 'hour' : 'hours'
          
        
      %td
        %i #{time_ago_in_words Time.at(project.pinches.last.end_time)} ago
      %td
        %a.tip{:href => "/mate?path=#{project.path}"} mate
      
.clear
